<?php
include ("../../../config/config.php");

if ($dbtype=="mssql") {
	$db = new db_mssql;
}
else {
	$db = new db_mysql;
}
$db->connect($dbhost,$dbuser,$dbpass,$dbname);



class db_mysql {

	var $linkID;

	function connect($dbhost, $dbuser, $dbpass, $dbname) {
		if ($this->linkID=mysql_connect($dbhost, $dbuser, $dbpass)) {
			mysql_select_db($dbname,$this->linkID);	
		}
		else {
			exit("Can not connect to MySQL server");
		}
	}

	function fetch_array($query) {
		return mysql_fetch_array($query);
	}

	function query($sql) {
		$query = mysql_query($sql,$this->linkID);
		return $query;
	}

	function result($query, $row) {
		$query = mysql_result($query, $row);
		return $query;
	}

	function num_rows($query) {
		$query = mysql_num_rows($query);
		return $query;
	}

	function sql_seek($query, $row) {
		return mysql_data_seek($query, $row);
	}

	function close() {
		@$tclose=mysql_close($this->linkID);
		return $tclose;
	}
}
class db_mssql {

	var $linkID;

	function connect($dbhost, $dbuser, $dbpass, $dbname) {
		if ($this->linkID=mssql_connect($dbhost, $dbuser, $dbpass)) {
			mssql_select_db($dbname,$this->linkID);
		}
		else {
			exit("Can not connect to SQL server");
		}
	}

	function fetch_array($query) {
		return mssql_fetch_array($query);
	}

	function query($sql) {
		$query = mssql_query($sql,$this->linkID);
		return $query;
	}

	function result($query, $row) {
		$query = mssql_result($query, $row);
		return $query;
	}

	function num_rows($query) {
		$query = mssql_num_rows($query);
		return $query;
	}

	function sql_seek($query, $row) {
		return mssql_data_seek($query, $row);
	}

	function close() {
		@$tclose=mssql_close($this->linkID);
		return $tclose;
	}
}
?>